module etc.dleveldb.filterpolicy;

import deimos.leveldb.c;

import std.exception;

abstract static class FilterPolicy
{
    ~this()
    {
        if(this.isValid){
            leveldb_filterpolicy_destroy(this._filterpolicy);
        }
        this._filterpolicy = null;
    }

    @property:

    bool isValid() const
    {
        return (this._filterpolicy !is null);
    }
    
    package:
    @property:

    inout(leveldb_filterpolicy_t*) ptr() inout
    {
        return this._filterpolicy;
    }


    protected:
    leveldb_filterpolicy_t*  _filterpolicy;
}

static class BloomFilterPolicy : FilterPolicy
{
    this()
    {
        this(10);
    }
    this(int bits_per_key)
    {
        enforce(_filterpolicy = leveldb_filterpolicy_create_bloom(bits_per_key), "Failed to create bloom filter policy");
    }

}

static class AFilterPolicy : FilterPolicy
{
    this()
    {
        //this._filterpolicy = leveldb_filterpolicy_create();
    }


}